<div id="main">
<form>
	<input type="hidden" name="types" value="{{$types}}">
</form>
<p class="text-center">
	<button :disabled="canSubmit" type="button" class="btn btn-primary" @click="doPost">@{{subText}}</button>
</p>
</div>
<link rel="stylesheet" href="{{URL::asset('vendor/element-ui/lib/theme-chalk/index.css')}}">
<link rel="stylesheet" href="{{URL::asset('vendor/element-ui/lib/theme-chalk/reset.style.css')}}">
<script src="{{URL::asset('vendor/element-ui/ext/vue.js')}}"></script>
<script src="{{URL::asset('vendor/element-ui/lib/index.js')}}"></script>
<script type="text/javascript">
let main = new Vue({
	el:"#main",
	data:{
		url:"",
		canSubmit:false,
		subText:"提交"
	},
	methods:{
		doPost() {
			const h = this.$createElement;
			this.$msgbox({
				title: '提示',
				message:"确认提交？",
				showCancelButton:true,
				closeOnClickModal:false,
				closeOnPressEscape:false,
				confirmButtonText: '确定',
				cancelButtonText: '关闭',
				beforeClose: (action, instance, done) => {
					if (action === 'confirm') {
						instance.confirmButtonLoading = true;
						instance.confirmButtonText = 'doing...';
						let params = $("form").serialize();
						let url = "/admin/study_jindu_confirm_save";
						$.post(url,params,function(res){
							if(res.code == 1){
								main.url = res.data;
								main.$notify({title:"Success",message:res.msg,type:"success"});
								instance.confirmButtonText = 'done';
								setTimeout(function(){
									done();
								},3000)
							}else{
								main.$notify.error({title:"Error",message:res.msg});
							}
						})
					}else{
						done();
					}
				},
				callback() {
					window.location.href = main.url;
				}
			}).catch(()=>{});
		},
	}
});
</script>
